#ifndef SIMPLE_LOGGER_CONTEXT_H
#define SIMPLE_LOGGER_CONTEXT_H
#include "simple_logger.h"

namespace mylog 
{
class SLoggerSample
{
public:
	~SLoggerSample() = default;
	static SLoggerSample& instance()
	{
		static SLoggerSample _instance;
		return _instance;
	}
	void init(const std::string& loggerName)
	{
		if (!_logger)
			_logger = std::make_shared<slog::SimpleLogger>(loggerName);
	}
	slog::LogContextCapture::Ptr operator()(slog::LogLevel level, const char* file, const char* funciton, int line)
	{
		auto capture = std::make_shared<slog::LogContextCapture>(_logger, level, file, funciton, line);
		return capture;
	}

protected:
	SLoggerSample() = default;

private:
	std::shared_ptr<slog::SimpleLogger> _logger;
};
}

#define WriteL(level) (*::mylog::SLoggerSample::instance()(level, __FILE__, __FUNCTION__, __LINE__))
#define LogTrace	WriteL(::slog::LTrace)
#define LogDebug	WriteL(::slog::LDebug)
#define LogInfo		WriteL(::slog::LInfo)
#define LogWarn		WriteL(::slog::LWarn)
#define LogError	WriteL(::slog::LError)

#endif //SIMPLE_LOGGER_CONTEXT_H
